Emacs 對於編輯 Go 程式的支援
# for go setup
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
go
├── bin
└── src
├── github.com
│ ├── jerryhsieh
│ │ └── myproject
在 Go workspace 下,執行以下指令來安裝
$go get golang.org/x/tools/cmd/goimports
$go get golang.org/x/tools/cmd/godoc
$go get github.com/rogpeppe/godef
$go get golang.org/x/tools/cmd/guru
$go get golang.org/x/lint/golint
$go get github.com/nsf/gocode
$go get golang.org/x/tools/cmd/gorename
安裝完後,Go workspace 應該像是
go
├── bin
│ ├── gocode
│ ├── godef
│ ├── godoc
│ ├── goimports
│ ├── golint
│ └── guru
└── src
├── github.com
│ ├── jerryhsieh
│ │ └── myproject
│ ├── nsf
│ │ └── gocode
│ └── rogpeppe
│ └── godef
└── golang.org
└── x
├── lint
└── tools
(use-package go-mode
:ensure t
:mode (("\\.go\\'" . go-mode))
:hook ((before-save . gofmt-before-save))
:config
(setq gofmt-command "goimports")
(use-package company-go
:ensure t
:config
(add-hook 'go-mode-hook (lambda()
(add-to-list (make-local-variable 'company-backends)
'(company-go company-files company-yasnippet company-capf))))
)
(use-package go-eldoc
:ensure t
:hook (go-mode . go-eldoc-setup)
)
(use-package go-guru
:ensure t
:hook (go-mode . go-guru-hl-identifier-mode)
)
(use-package go-rename
:ensure t)
)
相關影片:
相關簡報:簡報
相關程式: Github,請下載到 ~/.emacs.d/ 下,啟動 Emacs 會自動安裝各相關套件
相關資訊:請參考我的部落格